package com.baboba.rummy.card.arena;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.baboba.rummy.card.UserCard;
import com.baboba.rummy.card.validator.HorizontalValidator;
import com.baboba.rummy.card.validator.IValidator;
import com.baboba.rummy.card.validator.VerticalValidator;

public class CardSequence {
	private static IValidator<UserCard> hValidator = new HorizontalValidator<UserCard>();
	private static IValidator<UserCard> vValidator = new VerticalValidator<UserCard>();
	
	private List<UserCard> sequence;
	private int total;
	
	public CardSequence(){
		sequence = new ArrayList<UserCard>();
	}
	
	void add(UserCard card){
		sequence.add(card);
	}
	
	void add(UserCard[] cards){
		sequence.addAll(Arrays.asList(cards));
	}
	
	void redraw(UserCard card, int user){
		
	}
	
	public boolean validate(){
		if (hValidator.validate(sequence) && vValidator.validate(sequence))
			return true;
			
		return false;
	}

	public int getTotal() {
		return total;
	}
	
	public interface ChangeListener{
		public void onCardRemoved(UserCard card);
		public void onCardAdded(UserCard card);
		public void onValidateFailed();
	}
}
